package 题集.力扣.算法精选200.T0107_旋转矩阵;

/**
 * https://leetcode.cn/problems/rotate-matrix-lcci/
 * <p>
 * 题解：https://leetcode.cn/problems/rotate-image/solution/shun-shi-zhen-xuan-zhuan-90du-zhu-dui-jiao-xian-fa/
 */
class Solution {
    public void rotate(int[][] matrix) {
        int n = matrix.length;
        // 水平翻转
        for (int i = 0; i < n / 2; ++i) {
            for (int j = 0; j < n; ++j) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[n - i - 1][j];
                matrix[n - i - 1][j] = temp;
            }
        }

        // 主对角线翻转
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < i; ++j) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }
    }

    public static void main(String[] args) {
        int[][] arr = new int[][]{};
    }
}